<!Doctype html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0" />
	<title>Python3 元组 | 菜鸟教程</title>

  <meta name='robots' content='max-image-preview:large' />
<link rel='stylesheet' id='classic-theme-styles-css' href='../0/classic-themes.min.css?ver=6.2' type='text/css' media='all' />
<link rel="canonical" href="../python3/python3-tuple.html" />
<meta name="keywords" content="Python3 元组">
<meta name="description" content="Python3 元组  Python 的元组与列表类似，不同之处在于元组的元素不能修改。 元组使用小括号 ( )，列表使用方括号 [ ]。 元组创建很简单，只需要在括号中添加元素，并使用逗号隔开即可。    实例(Python 3.0+)   [mycode4 type=&#039;python&#039;] &gt;&gt;&gt; tup1 = (&#039;Google&#039;, &#039;Runoob&#039;, 199..">
		
	<link rel="shortcut icon" href="https://static.runoob.com/images/favicon.ico">
	<link rel="stylesheet" href="../0/style.css?v=1.170" type="text/css" media="all" />	
	<link rel="stylesheet" href="../0/font-awesome.min.css" media="all" />	
  <!--[if gte IE 9]><!-->
  <script src=""></script>
  <!--<![endif]-->
  <!--[if lt IE 9]>
     <script src=""></script>
     <script src=""></script>
  <![endif]-->
  <link rel="apple-touch-icon" href="https://static.runoob.com/images/icon/mobile-icon.png"/>
  <meta name="apple-mobile-web-app-title" content="菜鸟教程">
</head>
<body>

<!--  头部 -->
<div class="container logo-search">

  <div class="col search row-search-mobile">
    <form action="index.php">
      <input class="placeholder" placeholder="搜索……" name="s" autocomplete="off">
      
    </form>
  </div>

  <div class="row">
    <div class="col logo">
      <h1><a href="../">菜鸟教程 -- 学的不仅是技术，更是梦想！</a></h1>
    </div>
        <div class="col right-list"> 
    <button class="btn btn-responsive-nav btn-inverse" data-toggle="collapse" data-target=".nav-main-collapse" id="pull" style=""> <i class="fa fa-navicon"></i> </button>
    </div>
        
    <div class="col search search-desktop last">
      <div class="search-input" >
      <form action="//www.runoob.com/" target="_blank">
        <input class="placeholder" id="s" name="s" placeholder="搜索……"  autocomplete="off" style="height: 44px;">
      </form>
      
      </div>
    </div>
  </div>
</div>



<!-- 导航栏 -->
<!-- 导航栏 -->
<div class="container navigation">
	<div class="row">
		<div class="col nav">
			<ul class="pc-nav" id="runoob-detail-nav">
				<li><a href="../">首页</a></li>
				<li><a href="../html/html-tutorial.html">HTML</a></li>
				<li><a href="../css/css-tutorial.html">CSS</a></li>
				<li><a href="../js/js-tutorial.html">JavaScript</a></li>
				<li><a href="javascript:void(0);" data-id="vue">Vue</a></li>
				<li><a href="javascript:void(0);" data-id="bootstrap">Bootstrap</a></li>
				<li><a href="../nodejs/nodejs-tutorial.html">NodeJS</a></li>
				<li><a href="../python3/python3-tutorial.html">Python3</a></li>
				<li><a href="../python/python-tutorial.html">Python2</a></li>
				<li><a href="../java/java-tutorial.html">Java</a></li>
				<li><a href="../cprogramming/c-tutorial.html">C</a></li>
				<li><a href="../cplusplus/cpp-tutorial.html">C++</a></li>
				<li><a href="../csharp/csharp-tutorial.html">C#</a></li>
				<li><a href="../go/go-tutorial.html">Go</a></li>
				<li><a href="../sql/sql-tutorial.html">SQL</a></li>
				<li><a href="../linux/linux-tutorial.html">Linux</a></li>
				<li><a href="../jquery/jquery-tutorial.html">jQuery</a></li>
				<li><a href="../browser-history">本地书签</a></li>
				<!--
			
				<li><a href="../w3cnote/knowledge-start.html" style="font-weight: bold;" onclick="_hmt.push(['_trackEvent', '星球', 'click', 'start'])" title="我的圈子">我的圈子</a></li>				
				<li><a href="javascript:;" class="runoob-pop">登录</a></li>
				-->
      		</ul>
			<ul class="mobile-nav">
				<li><a href="../">首页</a></li>
				<li><a href="../html/html-tutorial.html">HTML</a></li>
				<li><a href="../css/css-tutorial.html">CSS</a></li>
				<li><a href="../js/js-tutorial.html">JS</a></li>
				<li><a href="../browser-history">本地书签</a></li>
				<li><a href="javascript:void(0)" class="search-reveal">Search</a> </li>
			</ul>
			
		</div>
	</div>
</div>

<div class="container sub-navigation sub-navigation-articles" style="display:none">
	<div class="row">
		<div class="col nav-sub">
		<ul id="python">
			<li class="cat-item"><a href="../python3/python3-tutorial.html">Python3 教程 <i class="fa fa-external-link" aria-hidden="true"></i></a></li>
			<li class="cat-item"><a href="../python/python-tutorial.html">Python2 教程 <i class="fa fa-external-link" aria-hidden="true"></i></a></li>
		</ul>
		<ul id="vue">
			<li class="cat-item"><a href="../vue3/vue3-tutorial.html">Vue3 教程 <i class="fa fa-external-link" aria-hidden="true"></i></a></li>
			<li class="cat-item"><a href="../vue/vue-tutorial.html">vue2 教程 <i class="fa fa-external-link" aria-hidden="true"></i></a></li>
		</ul>

		<ul id="bootstrap">
			<li class="cat-item"><a href="../bootstrap/bootstrap-tutorial.html">Bootstrap3 教程 <i class="fa fa-external-link" aria-hidden="true"></i></a></li>
			<li class="cat-item"><a href="../bootstrap4/bootstrap4-tutorial.html">Bootstrap4 教程 <i class="fa fa-external-link" aria-hidden="true"></i></a></li>
			<li class="cat-item"><a href="../bootstrap5/bootstrap5-tutorial.html">Bootstrap5 教程 <i class="fa fa-external-link" aria-hidden="true"></i></a></li>
			<li class="cat-item"><a href="../bootstrap/bootstrap-v2-tutorial.html">Bootstrap2 教程 <i class="fa fa-external-link" aria-hidden="true"></i></a></li>
		</ul>
		</div>
	</div>
</div><!--  内容  -->
<div class="container main">
	<!-- 中间 -->
	<div class="row">
	
<div class="runoob-col-md2">
<div class="left-column">
	<div class="tab" style="overflow: hidden;text-overflow: ellipsis;white-space: nowrap;">
	<i class="fa fa-list" aria-hidden="true"></i> 
	<span>Python 3 教程</span>
	<a data-cate="124" href="javascript:void(0);" title="夜间模式"  id="moon"><i class="fa fa-moon-o" aria-hidden="true" style="line-height: 28px;font-size: 1.2em;margin: 2px 4px 0;"></i></a>
	<a data-cate="124" style="display:none;" href="javascript:void(0);" title="日间模式"  id="sun" ><i class="fa fa-sun-o" aria-hidden="true" style="line-height: 28px;font-size: 1.2em;margin: 2px 4px 0;line-height: 28px;
}"></i></a>

	</div>
	<div class="sidebar-box gallery-list">
		<div class="design" id="leftcolumn">
						<a target="_top" title="Python3 教程"  href="../python3/python3-tutorial.html" >
			Python3 教程			</a>
			<a target="_top" title="Python3 简介" href="python3-intro.html" > Python3 简介 </a>
<a target="_top" title="Python3 环境搭建" href="python3-install.html" > Python3 环境搭建</a>
<a target="_top" title="Python3 VScode" href="python-vscode-setup.html"> Python3 VScode </a>
<a target="_top" title="Python3 基础语法" href="python3-basic-syntax.html" > Python3 基础语法 </a>
<a target="_top" title="Python3 基本数据类型" href="python3-data-type.html" > Python3 基本数据类型 </a>
<a target="_top" title="Python3  数据类型转换" href="python3-type-conversion.html" > Python3 数据类型转换 </a>
			<a target="_top" title="Python3 解释器"  href="../python3/python3-interpreter.html" >
			Python3 解释器			</a>
						<a target="_top" title="Python3 注释"  href="../python3/python3-comment.html" >
			Python3 注释			</a>
			<a target="_top" title="Python3 运算符" href="python3-basic-operators.html"> Python3 运算符 </a>			<a target="_top" title="Python3 数字(Number)"  href="../python3/python3-number.html" >
			Python3 数字(Number)			</a>
						<a target="_top" title="Python3 字符串"  href="../python3/python3-string.html" >
			Python3 字符串			</a>
						<a target="_top" title="Python3 列表"  href="../python3/python3-list.html" >
			Python3 列表			</a>
			<a target="_top" title="Python3 元组" href="python3-tuple.html"> Python3 元组 </a>
<a target="_top" title="Python3 字典" href="python3-dictionary.html"> Python3 字典</a>
<a target="_top" title="Python3 集合" href="python3-set.html"> Python3 集合</a>			<a target="_top" title="Python3 条件控制"  href="../python3/python3-conditional-statements.html" >
			Python3 条件控制			</a>
						<a target="_top" title="Python3 循环语句"  href="../python3/python3-loop.html" >
			Python3 循环语句			</a>
			<a target="_top" title="Python3 编程第一步" href="python3-step1.html"> Python3 编程第一步</a>
<a target="_top" title="Python3 推导式" href="python-comprehensions.html" > Python3 推导式 </a>
<a target="_top" title="Python3 迭代器与生成器" href="python3-iterator-generator.html"> Python3 迭代器与生成器</a>			<a target="_top" title="Python3 函数"  href="../python3/python3-function.html" >
			Python3 函数			</a>
						<a target="_top" title="Python3 数据结构"  href="../python3/python3-data-structure.html" >
			Python3 数据结构			</a>
						<a target="_top" title="Python3 模块"  href="../python3/python3-module.html" >
			Python3 模块			</a>
						<a target="_top" title="Python3 输入和输出"  href="../python3/python3-inputoutput.html" >
			Python3 输入和输出			</a>
			<a target="_top" title="Python3 File" href="python3-file-methods.html"> Python3 File </a>
<a target="_top" title="Python3 OS" href="python3-os-file-methods.html"> Python3 OS </a>			<a target="_top" title="Python3 错误和异常"  href="../python3/python3-errors-execptions.html" >
			Python3 错误和异常			</a>
						<a target="_top" title="Python3 面向对象"  href="../python3/python3-class.html" >
			Python3 面向对象			</a>
			<a target="_top" title=" Python3 命名空间/作用域" href="../python3/python3-namespace-scope.html"> Python3 命名空间/作用域</a>			<a target="_top" title="Python3 标准库概览"  href="../python3/python3-stdlib.html" >
			Python3 标准库概览			</a>
						<a target="_top" title="Python3 实例"  href="../python3/python3-examples.html" >
			Python3 实例			</a>
			<a target="_blank" title="Python 测验" href="../quiz/python-quiz.html"> Python 测验 </a>
<br><h2 class="left"><span class="left_h2">Python3</span> 高级教程</h2>			<a target="_top" title="Python3 正则表达式"  href="../python3/python3-reg-expressions.html" >
			Python3 正则表达式			</a>
						<a target="_top" title="Python3 CGI编程"  href="../python3/python3-cgi-programming.html" >
			Python3 CGI编程			</a>
			<a target="_top" title="Python MySQL - mysql-connector 驱动" href="python-mysql-connector.html">Python3 MySQL(mysql-connector)</a>			<a target="_top" title="Python3 MySQL 数据库连接 &#8211; PyMySQL 驱动"  href="../python3/python3-mysql.html" >
			Python3 MySQL(PyMySQL)			</a>
						<a target="_top" title="Python3 网络编程"  href="../python3/python3-socket.html" >
			Python3 网络编程			</a>
						<a target="_top" title="Python3 SMTP发送邮件"  href="../python3/python3-smtp.html" >
			Python3 SMTP发送邮件			</a>
						<a target="_top" title="Python3 多线程"  href="../python3/python3-multithreading.html" >
			Python3 多线程			</a>
						<a target="_top" title="Python3 XML 解析"  href="../python3/python3-xml-processing.html" >
			Python3 XML 解析			</a>
						<a target="_top" title="Python3 JSON 数据解析"  href="../python3/python3-json.html" >
			Python3 JSON			</a>
						<a target="_top" title="Python3 日期和时间"  href="../python3/python3-date-time.html" >
			Python3 日期和时间			</a>
						<a target="_top" title="Python3 内置函数"  href="../python3/python3-built-in-functions.html" >
			Python3 内置函数			</a>
						<a target="_top" title="Python MongoDB"  href="../python3/python-mongodb.html" >
			Python3 MongoDB			</a>
			<a target="_top" title="Python3 urllib" href="python-urllib.html"> Python3 urllib</a>			<a target="_top" title="Python uWSGI  安装配置"  href="../python3/python-uwsgi.html" >
			Python uWSGI  安装配置			</a>
						<a target="_top" title="Python3 pip"  href="../python3/python3-pip.html" >
			Python3 pip			</a>
						<a target="_top" title="Python3 operator 模块"  href="../python3/python-operator.html" >
			Python3 operator			</a>
						<a target="_top" title="Python math 模块"  href="../python3/python-math.html" >
			Python math			</a>
						<a target="_top" title="Python requests 模块"  href="../python3/python-requests.html" >
			Python requests			</a>
						<a target="_top" title="Python random 模块"  href="../python3/python-random.html" >
			Python random			</a>
						<a target="_top" title="Python 有用的资源"  href="../python3/python3-resources.html" >
			Python 有用的资源			</a>
						<a target="_top" title="Python AI 绘画"  href="../python3/python-ai-draw.html" >
			Python AI 绘画			</a>
				
		</div>
	</div>	
</div>
</div>	<div class="col middle-column">
		
	
	<div class="article">
		
		<div class="previous-next-links">
			<div class="previous-design-link"><i style="font-size:16px;" class="fa fa-arrow-left" aria-hidden="true"></i> <a href="../python3/python3-iterator-generator.html" rel="prev"> Python3 迭代器与生成器</a> </div>
			<div class="next-design-link"><a href="../python3/python3-dictionary.html" rel="next"> Python3 字典</a> <i style="font-size:16px;" class="fa fa-arrow-right" aria-hidden="true"></i></div>
		</div>
<div class="article-heading-ad" style="display: block;">
<script async src=""
     crossorigin="anonymous"></script>
<!-- 728*90 固定 -->
<ins class="adsbygoogle"
     style="display:inline-block;width:728px;height:90px"
     data-ad-client="ca-pub-5751451760833794"
     data-ad-slot="2147566827"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
		</div>
		<div class="article-body">
		
			<div class="article-intro" id="content">
			
			<h1>Python3 <span class="color_h1">元组</span></h1>

<p>Python 的元组与列表类似，不同之处在于元组的元素不能修改。</p>
<p>元组使用小括号 <span class="marked">( )</span>，列表使用方括号 <span class="marked">[ ]</span>。</p>
<p>元组创建很简单，只需要在括号中添加元素，并使用逗号隔开即可。</p>
<p><img decoding="async" src="https://www.runoob.com/wp-content/uploads/2016/04/tup-2020-10-27-10-26-2.png"></p>
<div class="example"> 
<h2 class="example">实例(Python 3.0+)</h2> 
<div class="example_code">

<span style="color: Gray;">&gt;&gt;&gt;</span> tup1 <span style="color: Gray;">=</span> <span style="color: Olive;">&#40;</span><span style="color: #a11;">'Google'</span><span style="color: Gray;">,</span> <span style="color: #a11;">'Runoob'</span><span style="color: Gray;">,</span> <span style="color: Maroon;">1997</span><span style="color: Gray;">,</span> <span style="color: Maroon;">2000</span><span style="color: Olive;">&#41;</span><br />
<span style="color: Gray;">&gt;&gt;&gt;</span> tup2 <span style="color: Gray;">=</span> <span style="color: Olive;">&#40;</span><span style="color: Maroon;">1</span><span style="color: Gray;">,</span> <span style="color: Maroon;">2</span><span style="color: Gray;">,</span> <span style="color: Maroon;">3</span><span style="color: Gray;">,</span> <span style="color: Maroon;">4</span><span style="color: Gray;">,</span> <span style="color: Maroon;">5</span> <span style="color: Olive;">&#41;</span><br />
<span style="color: Gray;">&gt;&gt;&gt;</span> tup3 <span style="color: Gray;">=</span> <span style="color: #a11;">&quot;a&quot;</span><span style="color: Gray;">,</span> <span style="color: #a11;">&quot;b&quot;</span><span style="color: Gray;">,</span> <span style="color: #a11;">&quot;c&quot;</span><span style="color: Gray;">,</span> <span style="color: #a11;">&quot;d&quot;</span> &nbsp; <span style="color: #a50"># &nbsp;不需要括号也可以</span><br />
<span style="color: Gray;">&gt;&gt;&gt;</span> <span style="color: Teal;">type</span><span style="color: Olive;">&#40;</span>tup3<span style="color: Olive;">&#41;</span><br />
<span style="color: Gray;">&lt;</span><span style="color: Green;font-weight:bold;">class</span> <span style="color: #a11;">'tuple'</span><span style="color: Gray;">&gt;</span><br />

</div>
</div>
<p>创建空元组</p>
<pre>
tup1 = ()
</pre>
<p>元组中只包含一个元素时，需要在元素后面添加逗号 <span class="marked">,</span> ，否则括号会被当作运算符使用：</p>
<div class="example"> 
<h2 class="example">实例(Python 3.0+)</h2> 
<div class="example_code">

<span style="color: Gray;">&gt;&gt;&gt;</span> tup1 <span style="color: Gray;">=</span> <span style="color: Olive;">&#40;</span><span style="color: Maroon;">50</span><span style="color: Olive;">&#41;</span><br />
<span style="color: Gray;">&gt;&gt;&gt;</span> <span style="color: Teal;">type</span><span style="color: Olive;">&#40;</span>tup1<span style="color: Olive;">&#41;</span> &nbsp; &nbsp; <span style="color: #a50"># 不加逗号，类型为整型</span><br />
<span style="color: Gray;">&lt;</span><span style="color: Green;font-weight:bold;">class</span> <span style="color: #a11;">'int'</span><span style="color: Gray;">&gt;</span><br />
<br />
<span style="color: Gray;">&gt;&gt;&gt;</span> tup1 <span style="color: Gray;">=</span> <span style="color: Olive;">&#40;</span><span style="color: Maroon;">50</span><span style="color: Gray;">,</span><span style="color: Olive;">&#41;</span><br />
<span style="color: Gray;">&gt;&gt;&gt;</span> <span style="color: Teal;">type</span><span style="color: Olive;">&#40;</span>tup1<span style="color: Olive;">&#41;</span> &nbsp; &nbsp; <span style="color: #a50"># 加上逗号，类型为元组</span><br />
<span style="color: Gray;">&lt;</span><span style="color: Green;font-weight:bold;">class</span> <span style="color: #a11;">'tuple'</span><span style="color: Gray;">&gt;</span><br />

</div>
</div>
<p>元组与字符串类似，下标索引从 0 开始，可以进行截取，组合等。</p>
<p><img decoding="async" src="https://www.runoob.com/wp-content/uploads/2016/04/py-tup-10-26.png"></p>
<hr><h2>访问元组</h2>
<p>元组可以使用下标索引来访问元组中的值，如下实例:</p>
<div class="example"> 
<h2 class="example">实例(Python 3.0+)</h2> 
<div class="example_code">
<div class="hl-main"><span class="hl-comment">#!/usr/bin/python3</span><span class="hl-code">
 
</span><span class="hl-identifier">tup1</span><span class="hl-code"> = </span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">Google</span><span class="hl-quotes">'</span><span class="hl-code">, </span><span class="hl-quotes">'</span><span class="hl-string">Runoob</span><span class="hl-quotes">'</span><span class="hl-code">, </span><span class="hl-number">1997</span><span class="hl-code">, </span><span class="hl-number">2000</span><span class="hl-brackets">)</span><span class="hl-code">
</span><span class="hl-identifier">tup2</span><span class="hl-code"> = </span><span class="hl-brackets">(</span><span class="hl-number">1</span><span class="hl-code">, </span><span class="hl-number">2</span><span class="hl-code">, </span><span class="hl-number">3</span><span class="hl-code">, </span><span class="hl-number">4</span><span class="hl-code">, </span><span class="hl-number">5</span><span class="hl-code">, </span><span class="hl-number">6</span><span class="hl-code">, </span><span class="hl-number">7</span><span class="hl-code"> </span><span class="hl-brackets">)</span><span class="hl-code">
 
</span><span class="hl-identifier">print</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-quotes">&quot;</span><span class="hl-string">tup1[0]: </span><span class="hl-quotes">&quot;</span><span class="hl-code">, </span><span class="hl-identifier">tup1</span><span class="hl-brackets">[</span><span class="hl-number">0</span><span class="hl-brackets">]</span><span class="hl-brackets">)</span><span class="hl-code">
</span><span class="hl-identifier">print</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-quotes">&quot;</span><span class="hl-string">tup2[1:5]: </span><span class="hl-quotes">&quot;</span><span class="hl-code">, </span><span class="hl-identifier">tup2</span><span class="hl-brackets">[</span><span class="hl-number">1</span><span class="hl-code">:</span><span class="hl-number">5</span><span class="hl-brackets">]</span><span class="hl-brackets">)</span></div>
</div>
</div>
<p>以上实例输出结果：</p>
<pre>
tup1[0]:  Google
tup2[1:5]:  (2, 3, 4, 5)
</pre>

<hr><h2>修改元组</h2>
<p>元组中的元素值是不允许修改的，但我们可以对元组进行连接组合，如下实例:</p>
<div class="example"> 
<h2 class="example">实例(Python 3.0+)</h2> 
<div class="example_code">
<div class="hl-main"><span class="hl-comment">#!/usr/bin/python3</span><span class="hl-code">
 
</span><span class="hl-identifier">tup1</span><span class="hl-code"> = </span><span class="hl-brackets">(</span><span class="hl-number">12</span><span class="hl-code">, </span><span class="hl-number">34.56</span><span class="hl-brackets">)</span><span class="hl-code">
</span><span class="hl-identifier">tup2</span><span class="hl-code"> = </span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">abc</span><span class="hl-quotes">'</span><span class="hl-code">, </span><span class="hl-quotes">'</span><span class="hl-string">xyz</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">
 
</span><span class="hl-comment"># 以下修改元组元素操作是非法的。</span><span class="hl-code">
</span><span class="hl-comment"># tup1[0] = 100</span><span class="hl-code">
 
</span><span class="hl-comment"># 创建一个新的元组</span><span class="hl-code">
</span><span class="hl-identifier">tup3</span><span class="hl-code"> = </span><span class="hl-identifier">tup1</span><span class="hl-code"> + </span><span class="hl-identifier">tup2</span><span class="hl-code">
</span><span class="hl-identifier">print</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-identifier">tup3</span><span class="hl-brackets">)</span></div>
</div>
</div>
<p>以上实例输出结果：</p>
<pre>
(12, 34.56, 'abc', 'xyz')
</pre>
<hr><h2>删除元组</h2>
<p>元组中的元素值是不允许删除的，但我们可以使用del语句来删除整个元组，如下实例:</p>
<div class="example"> 
<h2 class="example">实例(Python 3.0+)</h2> 
<div class="example_code">
<div class="hl-main"><span class="hl-comment">#!/usr/bin/python3</span><span class="hl-code">
 
</span><span class="hl-identifier">tup</span><span class="hl-code"> = </span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">Google</span><span class="hl-quotes">'</span><span class="hl-code">, </span><span class="hl-quotes">'</span><span class="hl-string">Runoob</span><span class="hl-quotes">'</span><span class="hl-code">, </span><span class="hl-number">1997</span><span class="hl-code">, </span><span class="hl-number">2000</span><span class="hl-brackets">)</span><span class="hl-code">
 
</span><span class="hl-identifier">print</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-identifier">tup</span><span class="hl-brackets">)</span><span class="hl-code">
</span><span class="hl-reserved">del</span><span class="hl-code"> </span><span class="hl-identifier">tup</span><span class="hl-code">
</span><span class="hl-identifier">print</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-quotes">&quot;</span><span class="hl-string">删除后的元组 tup : </span><span class="hl-quotes">&quot;</span><span class="hl-brackets">)</span><span class="hl-code">
</span><span class="hl-identifier">print</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-identifier">tup</span><span class="hl-brackets">)</span></div>
</div>
</div>
<p>以上实例元组被删除后，输出变量会有异常信息，输出如下所示：</p>
<pre>
删除后的元组 tup : 
Traceback (most recent call last):
  File "test.py", line 8, in &lt;module&gt;
    print (tup)
NameError: name 'tup' is not defined
</pre>
<hr><h2>元组运算符</h2>
<p>与字符串一样，元组之间可以使用 <span class="marked">+</span>、<span class="marked">+=</span>和 <span class="marked">*</span> 号进行运算。这就意味着他们可以组合和复制，运算后会生成一个新的元组。</p>
<table class="reference">
<tbody><tr>
<th style="width:33%">Python 表达式</th><th style="width:33%">结果 </th><th style="width:33%"> 描述</th></tr>
<tr><td><pre>len((1, 2, 3))</pre></td><td>3</td><td>计算元素个数</td></tr>
<tr><td><pre>
&gt;&gt;&gt; a = (1, 2, 3)
&gt;&gt;&gt; b = (4, 5, 6)
&gt;&gt;&gt; c = a+b
&gt;&gt;&gt; c
(1, 2, 3, 4, 5, 6)
</pre></td><td>(1, 2, 3, 4, 5, 6)</td><td>连接，c 就是一个新的元组，它包含了 a 和 b 中的所有元素。

 </td></tr>
<tr><td><pre>
&gt;&gt;&gt; a = (1, 2, 3)
&gt;&gt;&gt; b = (4, 5, 6)
&gt;&gt;&gt; a += b
&gt;&gt;&gt; a
(1, 2, 3, 4, 5, 6)
</pre></td><td>(1, 2, 3, 4, 5, 6)</td><td>连接，a 就变成了一个新的元组，它包含了 a 和 b 中的所有元素。</td></tr>


<tr><td><pre>('Hi!',) * 4</pre>

</td><td>('Hi!', 'Hi!', 'Hi!', 'Hi!')</td><td>复制</td></tr>
<tr><td><pre>3 in (1, 2, 3)</pre></td><td>True</td><td>元素是否存在</td></tr>
<tr><td><pre>
for x in (1, 2, 3): 
    print (x, end=" ")</pre></td><td>1 2 3</td><td>迭代 </td></tr>
</tbody></table>
<hr><h2>元组索引，截取</h2>
<p>因为元组也是一个序列，所以我们可以访问元组中的指定位置的元素，也可以截取索引中的一段元素，如下所示：</p>
<p>元组：</p>
<pre>
tup = ('Google', 'Runoob', 'Taobao', 'Wiki', 'Weibo','Weixin')
</pre>
<p><img decoding="async" src="https://www.runoob.com/wp-content/uploads/2016/04/py-tup-7.png"></p>
<table class="reference">
<tbody><tr>
<th style="width:33%">Python 表达式</th><th style="width:33%">结果 </th><th style="width:33%"> 描述</th></tr>
<tr><td>tup[1]</td><td>'Runoob'</td><td>读取第二个元素</td></tr>
<tr><td>tup[-2]</td><td>'Weibo'</td><td>反向读取，读取倒数第二个元素</td></tr>

<tr><td>tup[1:]</td><td>('Runoob', 'Taobao', 'Wiki', 'Weibo', 'Weixin')</td><td>截取元素，从第二个开始后的所有元素。</td></tr>
<tr><td>tup[1:4]</td><td>('Runoob', 'Taobao', 'Wiki')</td><td>截取元素，从第二个开始到第四个元素（索引为 3）。</td></tr>
</tbody></table>
<p>运行实例如下：</p>

<div class="example"><h2 class="example">实例</h2> <div class="example_code">
<span style="color: Gray;">&gt;&gt;&gt;</span> tup <span style="color: Gray;">=</span> <span style="color: Olive;">&#40;</span><span style="color: #a11;">'Google'</span><span style="color: Gray;">,</span> <span style="color: #a11;">'Runoob'</span><span style="color: Gray;">,</span> <span style="color: #a11;">'Taobao'</span><span style="color: Gray;">,</span> <span style="color: #a11;">'Wiki'</span><span style="color: Gray;">,</span> <span style="color: #a11;">'Weibo'</span><span style="color: Gray;">,</span><span style="color: #a11;">'Weixin'</span><span style="color: Olive;">&#41;</span><br />
<span style="color: Gray;">&gt;&gt;&gt;</span> tup<span style="color: Olive;">&#91;</span><span style="color: Maroon;">1</span><span style="color: Olive;">&#93;</span><br />
<span style="color: #a11;">'Runoob'</span><br />
<span style="color: Gray;">&gt;&gt;&gt;</span> tup<span style="color: Olive;">&#91;</span>-<span style="color: Maroon;">2</span><span style="color: Olive;">&#93;</span><br />
<span style="color: #a11;">'Weibo'</span><br />
<span style="color: Gray;">&gt;&gt;&gt;</span> tup<span style="color: Olive;">&#91;</span><span style="color: Maroon;">1</span>:<span style="color: Olive;">&#93;</span><br />
<span style="color: Olive;">&#40;</span><span style="color: #a11;">'Runoob'</span><span style="color: Gray;">,</span> <span style="color: #a11;">'Taobao'</span><span style="color: Gray;">,</span> <span style="color: #a11;">'Wiki'</span><span style="color: Gray;">,</span> <span style="color: #a11;">'Weibo'</span><span style="color: Gray;">,</span> <span style="color: #a11;">'Weixin'</span><span style="color: Olive;">&#41;</span><br />
<span style="color: Gray;">&gt;&gt;&gt;</span> tup<span style="color: Olive;">&#91;</span><span style="color: Maroon;">1</span>:<span style="color: Maroon;">4</span><span style="color: Olive;">&#93;</span><br />
<span style="color: Olive;">&#40;</span><span style="color: #a11;">'Runoob'</span><span style="color: Gray;">,</span> <span style="color: #a11;">'Taobao'</span><span style="color: Gray;">,</span> <span style="color: #a11;">'Wiki'</span><span style="color: Olive;">&#41;</span><br />
<span style="color: Gray;">&gt;&gt;&gt;</span> <br />
</div></div>



<hr><h2>元组内置函数</h2>
<p>Python元组包含了以下内置函数</p>
<table class="reference">
<tbody><tr>
<th style="width:5%">序号</th><th style="width:25%">方法及描述</th><th style="width:45%">实例</th></tr>

<tr><td>1</td><td>len(tuple)<br>计算元组元素个数。</td>
<td>
<pre>
&gt;&gt;&gt; tuple1 = ('Google', 'Runoob', 'Taobao')
&gt;&gt;&gt; len(tuple1)
3
&gt;&gt;&gt; 
</pre>
</td>
</tr>
<tr><td>2</td><td>max(tuple)<br>返回元组中元素最大值。</td>
<td>
<pre>
>>> tuple2 = ('5', '4', '8')
>>> max(tuple2)
'8'
>>> 
</td>

</tr>
<tr><td>3</td><td>min(tuple)<br>返回元组中元素最小值。</td>
<td>
<pre>
>>> tuple2 = ('5', '4', '8')
>>> min(tuple2)
'4'
>>> 
</td>
</tr>
<tr><td>4</td><td>tuple(iterable)<br>将可迭代系列转换为元组。</td>
<td>
<pre>
>>> list1= ['Google', 'Taobao', 'Runoob', 'Baidu']
>>> tuple1=tuple(list1)
>>> tuple1
('Google', 'Taobao', 'Runoob', 'Baidu')
</td>
</tr>
</tbody></table>

<h3>关于元组是不可变的</h3>
<p>所谓元组的不可变指的是元组所指向的内存中的内容不可变。</p>
<div class="example"> <div class="example_code">
<span style="color: Gray;">&gt;&gt;&gt;</span> tup <span style="color: Gray;">=</span> <span style="color: Olive;">&#40;</span><span style="color: #a11;">'r'</span><span style="color: Gray;">,</span> <span style="color: #a11;">'u'</span><span style="color: Gray;">,</span> <span style="color: #a11;">'n'</span><span style="color: Gray;">,</span> <span style="color: #a11;">'o'</span><span style="color: Gray;">,</span> <span style="color: #a11;">'o'</span><span style="color: Gray;">,</span> <span style="color: #a11;">'b'</span><span style="color: Olive;">&#41;</span><br />
<span style="color: Gray;">&gt;&gt;&gt;</span> tup<span style="color: Olive;">&#91;</span><span style="color: Maroon;">0</span><span style="color: Olive;">&#93;</span> <span style="color: Gray;">=</span> <span style="color: #a11;">'g'</span> &nbsp; &nbsp; <span style="color: #a50"># 不支持修改元素</span><br />
Traceback <span style="color: Olive;">&#40;</span>most recent call last<span style="color: Olive;">&#41;</span>:<br />
&nbsp; File <span style="color: #a11;">&quot;&lt;stdin&gt;&quot;</span><span style="color: Gray;">,</span> line <span style="color: Maroon;">1</span><span style="color: Gray;">,</span> <span style="color: Green;font-weight:bold;">in</span> <span style="color: Gray;">&lt;</span>module<span style="color: Gray;">&gt;</span><br />
<span style="color: Teal;">TypeError</span>: <span style="color: #a11;">'tuple'</span> <span style="color: Teal;">object</span> does <span style="color: Green;font-weight:bold;">not</span> support item assignment<br />
<span style="color: Gray;">&gt;&gt;&gt;</span> <span style="color: Teal;">id</span><span style="color: Olive;">&#40;</span>tup<span style="color: Olive;">&#41;</span> &nbsp; &nbsp; <span style="color: #a50"># 查看内存地址</span><br />
<span style="color: Maroon;">4440687904</span><br />
<span style="color: Gray;">&gt;&gt;&gt;</span> tup <span style="color: Gray;">=</span> <span style="color: Olive;">&#40;</span><span style="color: Maroon;">1</span><span style="color: Gray;">,</span><span style="color: Maroon;">2</span><span style="color: Gray;">,</span><span style="color: Maroon;">3</span><span style="color: Olive;">&#41;</span><br />
<span style="color: Gray;">&gt;&gt;&gt;</span> <span style="color: Teal;">id</span><span style="color: Olive;">&#40;</span>tup<span style="color: Olive;">&#41;</span><br />
<span style="color: Maroon;">4441088800</span> &nbsp; &nbsp;<span style="color: #a50"># 内存地址不一样了</span><br />
</div></div>

<p>
从以上实例可以看出，重新赋值的元组 tup，绑定到新的对象了，不是修改了原来的对象。</p>			<!-- 其他扩展 -->
						
			</div>
			
		</div>
		
		<div class="previous-next-links">
			<div class="previous-design-link"><i style="font-size:16px;" class="fa fa-arrow-left" aria-hidden="true"></i> <a href="../python3/python3-iterator-generator.html" rel="prev"> Python3 迭代器与生成器</a> </div>
			<div class="next-design-link"><a href="../python3/python3-dictionary.html" rel="next"> Python3 字典</a> <i style="font-size:16px;" class="fa fa-arrow-right" aria-hidden="true"></i></div>
		</div>
		<!-- 笔记列表 -->
		<style>
.wrapper {
  /*text-transform: uppercase; */
  background: #ececec;
  color: #555;
  cursor: help;
  font-family: "Gill Sans", Impact, sans-serif;
  font-size: 20px;
  position: relative;
  text-align: center;
  width: 200px;
  -webkit-transform: translateZ(0); /* webkit flicker fix */
  -webkit-font-smoothing: antialiased; /* webkit text rendering fix */
}

.wrapper .tooltip {
  white-space: nowrap;
  font-size: 14px;
  text-align: left;
  background: #96b97d;
  bottom: 100%;
  color: #fff;
  display: block;
  left: -25px;
  margin-bottom: 15px;
  opacity: 0;
  padding: 14px;
  pointer-events: none;
  position: absolute;
  
  -webkit-transform: translateY(10px);
     -moz-transform: translateY(10px);
      -ms-transform: translateY(10px);
       -o-transform: translateY(10px);
          transform: translateY(10px);
  -webkit-transition: all .25s ease-out;
     -moz-transition: all .25s ease-out;
      -ms-transition: all .25s ease-out;
       -o-transition: all .25s ease-out;
          transition: all .25s ease-out;
  -webkit-box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.28);
     -moz-box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.28);
      -ms-box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.28);
       -o-box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.28);
          box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.28);
}
.tooltip a {
	color:#fff;
}
/* This bridges the gap so you can mouse into the tooltip without it disappearing */
.wrapper .tooltip:before {
  bottom: -20px;
  content: " ";
  display: block;
  height: 20px;
  left: 0;
  position: absolute;
  width: 100%;
}  

/* CSS Triangles - see Trevor's post */
.wrapper .tooltip:after {
  border-left: solid transparent 10px;
  border-right: solid transparent 10px;
  border-top: solid #96b97d 10px;
  bottom: -10px;
  content: " ";
  height: 0;
  left: 20%;
  margin-left: -13px;
  position: absolute;
  width: 0;
}
.wrapper .tooltip1 {
	margin-left: 50px;
	padding-top: 0px;
}
/*
.wrapper:hover .tooltip {
  opacity: 1;
  pointer-events: auto;
  -webkit-transform: translateY(0px);
     -moz-transform: translateY(0px);
      -ms-transform: translateY(0px);
       -o-transform: translateY(0px);
          transform: translateY(0px);
}
*/
/* IE can just show/hide with no transition */
.lte8 .wrapper .tooltip {
  display: none;
}

.lte8 .wrapper:hover .tooltip {
  display: block;
}

</style>

<link rel="stylesheet" href="../0/upvotejs.css">
<script src=""></script>
<script src=""></script>
<div class="title" id="comments">
	<h2 class="">
    <div class="altblock">
				<i style="font-size:28px;margin-top: 8px;" class="fa fa-plus-square" aria-hidden="true"></i>
		    </div>
    <span class="mw-headline" id="qa_headline">11  篇笔记</span>
	<span class="mw-headline" id="user_add_note" style="float:right;line-height: 62px;padding-right: 14px;"><i class="fa fa-pencil-square-o" aria-hidden="true"></i>  写笔记</span>
    </h2>
</div>

<div id="postcomments"  style="display:none;" >
	<ol class="commentlist">
		<li class="comment even thread-even depth-1" id="comment-19824"><span class="comt-f">#0</span><div class="comt-avatar wrapper"><i style="font-size:36px;" class="fa fa-user-circle" aria-hidden="true"></i><div class="tooltip"><p><i class="fa fa-user" aria-hidden="true"></i>&nbsp;&nbsp;&nbsp;heisenbug601</p><p><i class="fa fa-envelope" aria-hidden="true"></i>&nbsp;&nbsp;601***902@qq.com</p><p><i class="fa fa-external-link" aria-hidden="true"></i> <a rel="nofollow" target="_blank" href="http://www.jb51.net/article/47986.htm">&nbsp;&nbsp;参考地址</a></p></div><div id="runoobvote-id-19824" data-commid = "19824" class="upvotejs"><a class="upvote"></a> <span class="count">272</span></div></div><div class="comt-main" id="div-comment-19824"><p>tuple和list非常类似，但是tuple一旦初始化就不能修改，比如同样是列出同学的名字：</p>

<p>代码如下：</p>

<pre>&gt;&gt;&gt; classmates = ('Michael', 'Bob', 'Tracy')</pre>

<p>现在，classmates这个tuple不能变了，它也没有append()，insert()这样的方法。其他获取元素的方法和list是一样的，你可以正常地使用classmates[0]，classmates[-1]，但不能赋值成另外的元素。不可变的tuple有什么意义？因为tuple不可变，所以代码更安全。如果可能，能用tuple代替list就尽量用tuple。tuple的陷阱：当你定义一个tuple时，在定义的时候，tuple的元素就必须被确定下来，比如：</p>

<p>代码如下：</p>

<pre>&gt;&gt;&gt; t = (1, 2)
&gt;&gt;&gt; t
(1, 2)</pre>

<p>如果要定义一个空的tuple，可以写成()：</p>

<p>代码如下：</p>

<pre>&gt;&gt;&gt; t = ()
&gt;&gt;&gt; t
()</pre>

<p>但是，要定义一个只有1个元素的tuple，如果你这么定义：</p>

<p>代码如下：</p>

<pre>&gt;&gt;&gt; t = (1)
&gt;&gt;&gt; t
1</pre>

<p>定义的不是tuple，是1这个数！这是因为括号()既可以表示tuple，又可以表示数学公式中的小括号，这就产生了歧义，因此，Python规定，这种情况下，按小括号进行计算，计算结果自然是1。</p>

<p>所以，只有1个元素的tuple定义时必须加一个逗号 <span class="marked">,</span>来消除歧义：</p>

<p>代码如下:</p>
<pre>
&gt;&gt;&gt; t = (1,)
&gt;&gt;&gt; t
(1,)</pre>

<p>Python在显示只有1个元素的tuple时，也会加一个逗号,，以免你误解成数学计算意义上的括号。</p>

<p>在来看一个"可变的"tuple：</p>

<p>代码如下:</p>

<pre>&gt;&gt;&gt; t = ('a', 'b', ['A', 'B'])
&gt;&gt;&gt; t[2][0] = 'X'
&gt;&gt;&gt; t[2][1] = 'Y'
&gt;&gt;&gt; t
('a', 'b', ['X', 'Y'])</pre>

<p>这个tuple定义的时候有3个元素，分别是'a'，'b'和一个list。不是说tuple一旦定义后就不可变了吗？怎么后来又变了？</p>

<p>别急，我们先看看定义的时候tuple包含的3个元素：当我们把list的元素'A'和'B'修改为'X'和'Y'后，tuple变为：表面上看，tuple的元素确实变了，但其实变的不是tuple的元素，而是list的元素。tuple一开始指向的list并没有改成别的list，所以，tuple所谓的"不变"是说，tuple的每个元素，指向永远不变。即指向'a'，就不能改成指向'b'，指向一个list，就不能改成指向其他对象，但指向的这个list本身是可变的！理解了"指向不变"后，要创建一个内容也不变的tuple怎么做？那就必须保证tuple的每一个元素本身也不能变。</p><div class="comt-meta wrapper"><span class="comt-author"><a target="_blank" href="javascript:;">heisenbug601</a><div class="tooltip tooltip1"><p><i class="fa fa-user" aria-hidden="true"></i>&nbsp;&nbsp;&nbsp;heisenbug601</p><p><i class="fa fa-envelope" aria-hidden="true"></i>&nbsp;&nbsp;601***902@qq.com</p><p><i class="fa fa-external-link" aria-hidden="true"></i> <a rel="nofollow" target="_blank" href="http://www.jb51.net/article/47986.htm">&nbsp;&nbsp;参考地址</a></p></div></span>6年前 (2017-11-04)</div></div></li><!-- #comment-## -->
<li class="comment odd alt thread-odd thread-alt depth-1" id="comment-22147"><span class="comt-f">#0</span><div class="comt-avatar wrapper"><i style="font-size:36px;" class="fa fa-user-circle" aria-hidden="true"></i><div class="tooltip"><p><i class="fa fa-user" aria-hidden="true"></i>&nbsp;&nbsp;&nbsp;run</p><p><i class="fa fa-envelope" aria-hidden="true"></i>&nbsp;&nbsp;hdr***11@gmail.com</p></div><div id="runoobvote-id-22147" data-commid = "22147" class="upvotejs"><a class="upvote"></a> <span class="count">104</span></div></div><div class="comt-main" id="div-comment-22147"><p>tuple元素不可变有一种特殊情况，当元素是可变对象时。对象内部属性是可以修改的！tuple的不可变限制只是在一个纬度上：元素的类型。实现理解，tuple的元素所保存的内容（数值或内存地址）是不允许修改的，但地址映射的对象自身是可以修改的。</p>

<pre>&gt;&gt;&gt; a = (1,[3,2])
&gt;&gt;&gt; a[1][0] = 1
&gt;&gt;&gt; a
(1, [1, 2])
&gt;&gt;&gt; a[1].append(3)
&gt;&gt;&gt; a
(1, [1, 2, 3])
&gt;&gt;&gt; del a[1][2]
&gt;&gt;&gt; a
(1, [1, 2])
&gt;&gt;&gt; del a[1]
Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
TypeError: 'tuple' object doesn't support item deletion
&gt;&gt;&gt; del a[1][1]
&gt;&gt;&gt; del a[1][0]
&gt;&gt;&gt; a
(1, [])
&gt;&gt;&gt;</pre>
<p>字符串是一种特殊的tuple,支持部分tuple的运算符</p>

<pre>
&gt;&gt;&gt; a = '12345'
&gt;&gt;&gt; a[2]
'3'
&gt;&gt;&gt; a[3:]
'45'
&gt;&gt;&gt; type(a)
&lt;class 'str'&gt;
&gt;&gt;&gt; a*2
'1234512345'
&gt;&gt;&gt; 6 in a
Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
TypeError: 'in &lt;string&gt;' requires string as left operand, not int
&gt;&gt;&gt; a
'12345'
&gt;&gt;&gt; for x in a: print(x)
... 
1
2
3
4
5
</pre><div class="comt-meta wrapper"><span class="comt-author"><a target="_blank" href="javascript:;">run</a><div class="tooltip tooltip1"><p><i class="fa fa-user" aria-hidden="true"></i>&nbsp;&nbsp;&nbsp;run</p><p><i class="fa fa-envelope" aria-hidden="true"></i>&nbsp;&nbsp;hdr***11@gmail.com</p></div></span>5年前 (2017-12-26)</div></div></li><!-- #comment-## -->
<li class="comment even thread-even depth-1" id="comment-25726"><span class="comt-f">#0</span><div class="comt-avatar wrapper"><i style="font-size:36px;" class="fa fa-user-circle" aria-hidden="true"></i><div class="tooltip"><p><i class="fa fa-user" aria-hidden="true"></i>&nbsp;&nbsp;&nbsp;mqslllduoduo</p><p><i class="fa fa-envelope" aria-hidden="true"></i>&nbsp;&nbsp;494***660@qq.com</p></div><div id="runoobvote-id-25726" data-commid = "25726" class="upvotejs"><a class="upvote"></a> <span class="count">91</span></div></div><div class="comt-main" id="div-comment-25726"><p data-title="Python namedtuple"><strong>Python元组的升级版本 -- namedtuple(具名元组)</strong></p>

<p>因为元组的局限性：不能为元组内部的数据进行命名，所以往往我们并不知道一个元组所要表达的意义，所以在这里引入了 <span class="marked">collections.namedtuple</span> 这个工厂函数，来构造一个带字段名的元组。具名元组的实例和普通元组消耗的内存一样多，因为字段名都被存在对应的类里面。这个类跟普通的对象实例比起来也要小一些，因为 Python 不会用 __dict__ 来存放这些实例的属性。</p>
<p>namedtuple 对象的定义如以下格式：</p>
<pre>collections.namedtuple(typename, field_names, verbose=False, rename=False) </pre>

<p>返回一个具名元组子类 typename，其中参数的意义如下： </p>
<ul><li>
<strong>typename</strong>：元组名称 </li><li>
<strong>field_names</strong>: 元组中元素的名称  </li><li>
<strong>rename</strong>: 如果元素名称中含有 python 的关键字，则必须设置为 rename=True </li><li>
<strong>verbose</strong>: 默认就好 </li></ul>
<p>下面来看看声明一个具名元组及其实例化的方法：</p>

<pre>import collections

# 两种方法来给 namedtuple 定义方法名
#User = collections.namedtuple('User', ['name', 'age', 'id'])
User = collections.namedtuple('User', 'name age id')
user = User('tester', '22', '464643123')

print(user)</pre>
<p><span class="marked">collections.namedtuple('User', 'name age id')</span> 创建一个具名元组，需要两个参数，一个是类名，另一个是类的各个字段名。后者可以是有多个字符串组成的可迭代对象，或者是有空格分隔开的字段名组成的字符串（比如本示例）。具名元组可以通过字段名或者位置来获取一个字段的信息。</p>
<p>输出结果：</p>
<pre>User(name='tester', age='22', id='464643123')</pre>


<p><strong>具名元组的特有属性:</strong></p>
类属性 <span class="marked">_fields</span>：包含这个类所有字段名的元组
类方法 <span class="marked">_make(iterable)</span>：接受一个可迭代对象来生产这个类的实例
实例方法 <span class="marked">_asdict()</span>：把具名元组以 collections.OrdereDict 的形式返回，可以利用它来把元组里的信息友好的展示出来
<pre>
from collections import namedtuple

# 定义一个namedtuple类型User，并包含name，sex和age属性。
User = namedtuple('User', ['name', 'sex', 'age'])

# 创建一个User对象
user = User(name='Runoob', sex='male', age=12)

# 获取所有字段名
print( user._fields )

# 也可以通过一个list来创建一个User对象，这里注意需要使用"_make"方法
user = User._make(['Runoob', 'male', 12])

print( user )
# User(name='user1', sex='male', age=12)

# 获取用户的属性
print( user.name )
print( user.sex )
print( user.age )

# 修改对象属性，注意要使用"_replace"方法
user = user._replace(age=22)
print( user )
# User(name='user1', sex='male', age=21)

# 将User对象转换成字典，注意要使用"_asdict"
print( user._asdict() )
# OrderedDict([('name', 'Runoob'), ('sex', 'male'), ('age', 22)])
</pre>
<p>以上实例输出结果为：</p>
<pre>('name', 'sex', 'age')
User(name='Runoob', sex='male', age=12)
Runoob
male
12
User(name='Runoob', sex='male', age=22)
OrderedDict([('name', 'Runoob'), ('sex', 'male'), ('age', 22)])</pre>
<div class="comt-meta wrapper"><span class="comt-author"><a target="_blank" href="../note/25726">mqslllduoduo</a><div class="tooltip tooltip1"><p><i class="fa fa-user" aria-hidden="true"></i>&nbsp;&nbsp;&nbsp;mqslllduoduo</p><p><i class="fa fa-envelope" aria-hidden="true"></i>&nbsp;&nbsp;494***660@qq.com</p></div></span>5年前 (2018-03-30)</div></div></li><!-- #comment-## -->
<li class="comment odd alt thread-odd thread-alt depth-1" id="comment-28875"><span class="comt-f">#0</span><div class="comt-avatar wrapper"><i style="font-size:36px;" class="fa fa-user-circle" aria-hidden="true"></i><div class="tooltip"><p><i class="fa fa-user" aria-hidden="true"></i>&nbsp;&nbsp;&nbsp;章鱼二哥</p><p><i class="fa fa-envelope" aria-hidden="true"></i>&nbsp;&nbsp;490***6@qq.com</p></div><div id="runoobvote-id-28875" data-commid = "28875" class="upvotejs"><a class="upvote"></a> <span class="count">47</span></div></div><div class="comt-main" id="div-comment-28875"><p><strong>元组的一些特殊需求实现</strong></p>

<p>1、定义元组后，根据不同的情形增加新的元组内容</p>


<pre>t1=(1,2,3)
for i in range(1,5):
    t2=(i,)
    t1=t1+t2
print(t1)</pre>


<p>输出为：</p>


<pre>(1, 2, 3, 1, 2, 3, 4)</pre>




<p>2、修改元组内的特定位置的值</p>


<pre>t1=(1,2,3)
for i in range(1,5):
    t2=(i,)
    t1=t1+t2
print(t1)

l1=list(t1)
print(l1)

l1[0]=9
print(l1)

t1=tuple(l1)
print(t1)
</pre>

<p>输出为：</p>


<pre>(1, 2, 3, 1, 2, 3, 4)
[1, 2, 3, 1, 2, 3, 4]
[9, 2, 3, 1, 2, 3, 4]
(9, 2, 3, 1, 2, 3, 4)</pre><div class="comt-meta wrapper"><span class="comt-author"><a target="_blank" href="javascript:;">章鱼二哥</a><div class="tooltip tooltip1"><p><i class="fa fa-user" aria-hidden="true"></i>&nbsp;&nbsp;&nbsp;章鱼二哥</p><p><i class="fa fa-envelope" aria-hidden="true"></i>&nbsp;&nbsp;490***6@qq.com</p></div></span>5年前 (2018-06-28)</div></div></li><!-- #comment-## -->
<li class="comment even thread-even depth-1" id="comment-28942"><span class="comt-f">#0</span><div class="comt-avatar wrapper"><i style="font-size:36px;" class="fa fa-user-circle" aria-hidden="true"></i><div class="tooltip"><p><i class="fa fa-user" aria-hidden="true"></i>&nbsp;&nbsp;&nbsp;tt</p><p><i class="fa fa-envelope" aria-hidden="true"></i>&nbsp;&nbsp;308***149@qq.com</p></div><div id="runoobvote-id-28942" data-commid = "28942" class="upvotejs"><a class="upvote"></a> <span class="count">29</span></div></div><div class="comt-main" id="div-comment-28942"><p>元组所指向的内存实际上保存的是元组内数据的内存地址集合（即 <strong>t[0], t[1]...t[n]</strong> 的内存地址），且元组一旦建立，这个集合就不能增加修改删除，一旦集合内的地址发生改变，必须重新分配元组空间保存新的地址集（元组类似 C 语言里的指针数组，只不过这个数组不能被修改）。</p>

<p>测试下面代码：</p>

<pre>print("连接前：")
t1=(1,2,"3")
t2=("4",5,["d1","d2"])
print("t1=",t1)
print("t2=",t2)
print("t1:",id(t1))
print("t2:",id(t2))
print("t1[0]:",id(t1[0]))
print("t1[1]:",id(t1[1]))
print("t1[2]:",id(t1[2]))
print("t2[0]:",id(t2[0]))
print("t2[1]:",id(t2[1]))
print("t2[2]:",id(t2[2]))
print("连接后：")
t1= t1+t2
print("t1(t1+t2):",id(t1))
print("t1[0]:",id(t1[0]))
print("t1[1]:",id(t1[1]))
print("t1[2]:",id(t1[2]))
print("t1[3]:",id(t1[3]))
print("t1[4]:",id(t1[4]))
print("t1[5]:",id(t1[5]))
t1[5].append("d3")
print("t1[5]增加d3:")
print("t1[5]=",t1[5])
print("t1[5]:",id(t1[5]))
print("t2=",t2)</pre>

<p>输出：</p>

<pre>连接前：
t1= (1, 2, '3')
t2= ('4', 5, ['d1', 'd2'])
t1: 1719219799168
t2: 1719219799528
t1[0]: 1378249760
t1[1]: 1378249792
t1[2]: 1719200188208
t2[0]: 1719199042336
t2[1]: 1378249888
t2[2]: 1719219441608
连接后：
t1(t1+t2): 1719222365256
t1[0]: 1378249760
t1[1]: 1378249792
t1[2]: 1719200188208
t1[3]: 1719199042336
t1[4]: 1378249888
t1[5]: 1719219441608
t1[5]增加d3:
t1[5]= ['d1', 'd2', 'd3']
t1[5]: 1719219441608
t2= ('4', 5, ['d1', 'd2', 'd3'])</pre>

<p>测试结论：元组 <strong>t1</strong> 跟 <strong>t2</strong> 连接并赋值 <strong>t1</strong> 后，<strong>t1</strong> 地址发生变化（因地址集合变化），<strong>t1[0], t1[1], t1[2], t2[0], t2[1], t2[2]</strong> 地址不变且保存在连接后的 <strong>t1</strong>，元组内数据根据自身类型确定是否可修改值（<b>t1[0]..t1[4]</b> 分别为不可修改的数据类型，<strong>t1[5]</strong> 为可修改的列表），连接后 <strong>t1[5]</strong> 跟 <strong>t2[2]</strong> 地址一样，<strong>t1[5]</strong> 变化将会导致 <strong>t2[2]</strong> 变化。
</p>
<div class="comt-meta wrapper"><span class="comt-author"><a target="_blank" href="javascript:;">tt</a><div class="tooltip tooltip1"><p><i class="fa fa-user" aria-hidden="true"></i>&nbsp;&nbsp;&nbsp;tt</p><p><i class="fa fa-envelope" aria-hidden="true"></i>&nbsp;&nbsp;308***149@qq.com</p></div></span>5年前 (2018-06-30)</div></div></li><!-- #comment-## -->
<li class="comment odd alt thread-odd thread-alt depth-1" id="comment-29798"><span class="comt-f">#0</span><div class="comt-avatar wrapper"><i style="font-size:36px;" class="fa fa-user-circle" aria-hidden="true"></i><div class="tooltip"><p><i class="fa fa-user" aria-hidden="true"></i>&nbsp;&nbsp;&nbsp;邪王真眼喵</p><p><i class="fa fa-envelope" aria-hidden="true"></i>&nbsp;&nbsp;112***1525@qq.com</p></div><div id="runoobvote-id-29798" data-commid = "29798" class="upvotejs"><a class="upvote"></a> <span class="count">26</span></div></div><div class="comt-main" id="div-comment-29798"><p>通过间接方法修改元组：</p>

<pre>tuple1 = (1,2,4,5)
tuple2 = tuple1[:2] + (3,) + tuple1[2:]
print(tuple2)</pre>
<p>输出结果为：</p>
<pre>(1, 2, 3, 4, 5)</pre>
<div class="comt-meta wrapper"><span class="comt-author"><a target="_blank" href="javascript:;">邪王真眼喵</a><div class="tooltip tooltip1"><p><i class="fa fa-user" aria-hidden="true"></i>&nbsp;&nbsp;&nbsp;邪王真眼喵</p><p><i class="fa fa-envelope" aria-hidden="true"></i>&nbsp;&nbsp;112***1525@qq.com</p></div></span>5年前 (2018-07-18)</div></div></li><!-- #comment-## -->
<li class="comment even thread-even depth-1" id="comment-41970"><span class="comt-f">#0</span><div class="comt-avatar wrapper"><i style="font-size:36px;" class="fa fa-user-circle" aria-hidden="true"></i><div class="tooltip"><p><i class="fa fa-user" aria-hidden="true"></i>&nbsp;&nbsp;&nbsp;嘻嘻</p><p><i class="fa fa-envelope" aria-hidden="true"></i>&nbsp;&nbsp;107***3848@qq.com</p></div><div id="runoobvote-id-41970" data-commid = "41970" class="upvotejs"><a class="upvote"></a> <span class="count">43</span></div></div><div class="comt-main" id="div-comment-41970"><p><b>关于如何修改元组的几个脱裤子放屁的方法：</b></p>

<pre># 方法一，赋值修改法
tup = (4,5,6,7,8) 
tup = ('谁', '说', '元', '组', '不', '能', '改')
print(tup)
#输出： ('谁', '说', '元', '组', '不', '能', '改')


#方法二、中间变量法
tup = (4, 6, 7,8, 9, 10 ,0)
tup = list(tup)
list2 = ['谁', '说', '元', '组', '不', '能', '改']
for i in range(7):
    tup[i] = list2[i]
print(tup)
#输出： ['谁', '说', '元', '组', '不', '能', '改']</pre><div class="comt-meta wrapper"><span class="comt-author"><a target="_blank" href="javascript:;">嘻嘻</a><div class="tooltip tooltip1"><p><i class="fa fa-user" aria-hidden="true"></i>&nbsp;&nbsp;&nbsp;嘻嘻</p><p><i class="fa fa-envelope" aria-hidden="true"></i>&nbsp;&nbsp;107***3848@qq.com</p></div></span>4年前 (2019-04-18)</div></div></li><!-- #comment-## -->
<li class="comment odd alt thread-odd thread-alt depth-1" id="comment-51419"><span class="comt-f">#0</span><div class="comt-avatar wrapper"><i style="font-size:36px;" class="fa fa-user-circle" aria-hidden="true"></i><div class="tooltip"><p><i class="fa fa-user" aria-hidden="true"></i>&nbsp;&nbsp;&nbsp;kwaaiikweis</p><p><i class="fa fa-envelope" aria-hidden="true"></i>&nbsp;&nbsp;335***7519@qq.com</p></div><div id="runoobvote-id-51419" data-commid = "51419" class="upvotejs"><a class="upvote"></a> <span class="count">121</span></div></div><div class="comt-main" id="div-comment-51419"><p><b>针对楼上的元组可以被修改的问题：</b></p><p>元组本身是不能被修改的，楼上朋友的方法会创建一个新元组，只是旧元组的名字被重新赋予了新的元组而已，原来的元组还存在，并与新元组的id不一样。</p><pre>&gt;&gt;&gt; tup = (4,5,6,7,8)
&gt;&gt;&gt; id(tup)
1953675198920
&gt;&gt;&gt; tup = ('谁', '说', '元', '组', '不', '能', '改')
&gt;&gt;&gt; id(tup)
195367</pre><p>可以发现，这两个元组的id并不一样，只是引用同一个元组名可能会引起误解</p><div class="comt-meta wrapper"><span class="comt-author"><a target="_blank" href="javascript:;">kwaaiikweis</a><div class="tooltip tooltip1"><p><i class="fa fa-user" aria-hidden="true"></i>&nbsp;&nbsp;&nbsp;kwaaiikweis</p><p><i class="fa fa-envelope" aria-hidden="true"></i>&nbsp;&nbsp;335***7519@qq.com</p></div></span>3年前 (2020-03-10)</div></div></li><!-- #comment-## -->
<li class="comment even thread-even depth-1" id="comment-56404"><span class="comt-f">#0</span><div class="comt-avatar wrapper"><i style="font-size:36px;" class="fa fa-user-circle" aria-hidden="true"></i><div class="tooltip"><p><i class="fa fa-user" aria-hidden="true"></i>&nbsp;&nbsp;&nbsp;追~</p><p><i class="fa fa-envelope" aria-hidden="true"></i>&nbsp;&nbsp;140***7803@qq.com</p></div><div id="runoobvote-id-56404" data-commid = "56404" class="upvotejs"><a class="upvote"></a> <span class="count">19</span></div></div><div class="comt-main" id="div-comment-56404"><p><b>针对楼上的<b>楼上的</b>元组可以被修改的问题：</b></p>

<pre># 方法二、中间变量法tup = (4, 6, 7, 8, 9, 10, 0)
print(id(tup), type(tup))
tup = list(tup)
print(id(tup), type(tup))
list2 = ['谁', '说', '元', '组', '不', '能', '改']
for i in range(7):
    tup[i] = list2[i]
print(tup)
print(id(tup), type(tup))

# 输出：
# ('谁', '说', '元', '组', '不', '能', '改')
# 1966736640800 &lt;class 'tuple'&gt;
# 1966738690368 &lt;class 'list'&gt;
# ['谁', '说', '元', '组', '不', '能', '改']
# 2260936151168 &lt;class 'list'&gt;</pre><p>
第二步就已经是列表了，所以后来改的是列表。</p><div class="comt-meta wrapper"><span class="comt-author"><a target="_blank" href="javascript:;">追~</a><div class="tooltip tooltip1"><p><i class="fa fa-user" aria-hidden="true"></i>&nbsp;&nbsp;&nbsp;追~</p><p><i class="fa fa-envelope" aria-hidden="true"></i>&nbsp;&nbsp;140***7803@qq.com</p></div></span>3年前 (2020-08-20)</div></div></li><!-- #comment-## -->
<li class="comment byuser comment-author-tianqixin bypostauthor odd alt thread-odd thread-alt depth-1" id="comment-62104"><span class="comt-f">#0</span><div class="comt-avatar wrapper"><i style="font-size:36px;" class="fa fa-user-circle" aria-hidden="true"></i><div class="tooltip"><p><i class="fa fa-user" aria-hidden="true"></i>&nbsp;&nbsp;&nbsp;Code</p><p><i class="fa fa-envelope" aria-hidden="true"></i>&nbsp;&nbsp;nyu***@163.com</p></div><div id="runoobvote-id-62104" data-commid = "62104" class="upvotejs"><a class="upvote"></a> <span class="count">12</span></div></div><div class="comt-main" id="div-comment-62104"><p>元组不可变的前提是元组内只能包含单一元素，例如：字符串、数字等</p><p>但当元组中包含数组时，元组中的数组内容时可更改的，且元组的id未改变。</p><p>这意味着元组的内容可变，当然，这实际还是改变的是数组的值。</p>
<pre>T = ('google', [0, 1, 2, 3, 4])
print(id(T), T)
T[1][0] = 99
print(id(T), T)</pre>

<p>输出：</p>
<pre>3212880643136 ('google', [0, 1, 2, 3, 4])
3212880643136 ('google', [99, 1, 2, 3, 4])</pre>
<div class="comt-meta wrapper"><span class="comt-author"><a target="_blank" href="javascript:;">Code</a><div class="tooltip tooltip1"><p><i class="fa fa-user" aria-hidden="true"></i>&nbsp;&nbsp;&nbsp;Code</p><p><i class="fa fa-envelope" aria-hidden="true"></i>&nbsp;&nbsp;nyu***@163.com</p></div></span>2年前 (2021-03-11)</div></div></li><!-- #comment-## -->
<li class="comment even thread-even depth-1" id="comment-65812"><span class="comt-f">#0</span><div class="comt-avatar wrapper"><i style="font-size:36px;" class="fa fa-user-circle" aria-hidden="true"></i><div class="tooltip"><p><i class="fa fa-user" aria-hidden="true"></i>&nbsp;&nbsp;&nbsp;於黾</p><p><i class="fa fa-envelope" aria-hidden="true"></i>&nbsp;&nbsp;252***70@qq.com</p></div><div id="runoobvote-id-65812" data-commid = "65812" class="upvotejs"><a class="upvote"></a> <span class="count">44</span></div></div><div class="comt-main" id="div-comment-65812"><p><strong data-title="Python 元组的装包与拆包">元组的装包与拆包</strong></p>

<p>Python中，元组装包拆包是自动的，不需要任何函数，导致很多人对于函数返回值一会有括号一会没括号非常迷惑</p>

<p>先看代码：</p>

<pre>a=1,2,3
#它其实等价于下面的代码
a=(1,2,3)
#因为等号左边只有1个变量，而等号右边有3个值，因此自动装包成为一个元组</pre><p>
再看下面的代码：</p>

<pre>a,b,c=(1,2,3)
#自动拆包，得到a=1,b=2,c=3</pre><p>
当函数return的时候，其实只能return一个值，并不能return多个值</p>
<p>
有人会问，我return了多个值也没有报错啊，运行很正常</p><p>

那正是因为Python将多个返回值自动装包造成的</p><p>

因此当你返回多个变量，而外面只用一个变量去接收，会接收到一个元组</p><p>

而当你用多个变量去接，就能对应的接收到每个值，这是因为自动拆包</p><p>

理解了这一点，对于理解函数返回值、字典中的键值对等等都是有帮助的</p>
<p>=========================================================</p>

<p>为了加强理解，再看最后一组代码：</p><pre>
a=10
b=20
a,b=b,a,1</pre><p>
执行会报错：<strong>too many values to unpack</strong></p>
<p>
这里很明显的，告诉你元组里有3个值需要拆包，而你只用2个值去接收，证明了元组确实执行了一个拆包的动作</p><div class="comt-meta wrapper"><span class="comt-author"><a target="_blank" href="../note/65812">於黾</a><div class="tooltip tooltip1"><p><i class="fa fa-user" aria-hidden="true"></i>&nbsp;&nbsp;&nbsp;於黾</p><p><i class="fa fa-envelope" aria-hidden="true"></i>&nbsp;&nbsp;252***70@qq.com</p></div></span>2年前 (2021-08-06)</div></div></li><!-- #comment-## -->
	</ol>
	<div class="pagenav">
			</div>
</div>
<div id="respond" class="no_webshot"> 
		<div class="comment-signarea" style="display:none; padding: 20px 20px;"> 
	<h3 class="text-muted" id="share_code" style="color: #799961;"><i class="fa fa-pencil-square-o" aria-hidden="true"></i> 点我分享笔记</h3>
	<!--
	<p style="font-size:14px;">笔记需要是本篇文章的内容扩展！</p><br>
	<p style="font-size:12px;"><a href="../tougao" target="_blank">文章投稿，可点击这里</a></p>
	<p style="font-size:14px;"><a href="../w3cnote/runoob-user-test-intro.html#invite" target="_blank">注册邀请码获取方式</a></p>
		<h3 class="text-muted"><i class="fa fa-info-circle" aria-hidden="true"></i> 分享笔记前必须<a href="javascript:;" class="runoob-pop">登录</a>！</h3>
		<p><a href="../w3cnote/runoob-user-test-intro.html#invite" target="_blank">注册邀请码获取方式</a></p>-->
	</div>
		
	<form action="/wp-content/themes/runoob/option/addnote.php" method="post" id="commentform" style="display:none;">
		<div class="comt">
			<div class="comt-title">
				<i style="font-size:36px;" class="fa fa-user-circle" aria-hidden="true"></i>				<p><a id="cancel-comment-reply-link" href="javascript:;">取消</a></p>
			</div>
			<div class="comt-box">
			<div id="mded"></div>
			
				<div class="comt-ctrl">
					<div class="comt-tips"><input type='hidden' name='comment_post_ID' value='15437' id='comment_post_ID' />
<input type='hidden' name='comment_parent' id='comment_parent' value='0' />
</div>
					<button type="submit" name="submit" id="submit" tabindex="5"><i class="fa fa-pencil" aria-hidden="true"></i> 分享笔记</button>
				</div>
			</div>
		
				
					<div class="comt-comterinfo"> 
						<ul id="comment-author-info">
							<li class="form-inline"><label class="hide" for="author">昵称</label><input class="ipt" type="text" name="author" id="author" value="" tabindex="2" placeholder="昵称"><span class="text-muted">昵称 (必填)</span></li>
							<li class="form-inline"><label class="hide" for="email">邮箱</label><input class="ipt" type="text" name="email" id="email" value="" tabindex="3" placeholder="邮箱"><span class="text-muted">邮箱 (必填)</span></li>
							<li class="form-inline"><label class="hide" for="url">引用地址</label><input class="ipt" type="text" name="url" id="url" value="" tabindex="4" placeholder="引用地址"><span class="text-muted">引用地址</span></li>
						</ul>
					</div>
				
			
		</div>

	</form>
	</div>
<script type="text/javascript">
$(function() {
	//初始化编辑器
	
	var editor = new Simditor({
	  textarea: $('#mded'),
	  placeholder: '写笔记...',
	  upload:false,
	 // upload: {url:'/api/comment_upload_file.php',params: null,fileKey: 'upload_file',connectionCount: 1,leaveConfirm: '文件正在上传，您确定离开?'},
	  defaultImage: 'https://www.runoob.com/images/logo.png',
	  codeLanguages: '',
	  autosave: 'editor-content',
	  toolbar: [  'bold','code','ul','ol','image' ]
	});
	editor.on('selectionchanged', function() {
		$(".code-popover").hide();
	});

	// 提交数据
	$("#share_code").click(function() {
		$(".comment-signarea").hide();
		$("#commentform").show();
		
	});
	$("#user_add_note").click(function() {
		$(".comment-signarea").hide();
		$("#commentform").show();
		$('html, body').animate({
       	    scrollTop: $("#respond").offset().top
    	}, 200);
	});

	// 提交笔记
	var commentform=$('#commentform');
	commentform.prepend('<div id="comment-status" style="display:none;" ></div>');
	var statusdiv=$('#comment-status');
	
	commentform.submit(function(e){
		e.preventDefault();
		var noteContent = editor.getValue();
		// console.log(noteContent);
		noteContent = noteContent.replace(/<pre><code>/g,"<pre>");
		noteContent = noteContent.replace(/<\/code><\/pre>/g,"</pre>");
		
		// 系列化表单数据
		var comment_parent = 0;
		var is_user_logged_in = $("#is_user_logged_in").val();
		var comment_post_ID =  15437;
		var _wp_unfiltered_html_comment = $("#_wp_unfiltered_html_comment").val();
		var comment = noteContent;
		var author = $("#author").val();
		var url = $("#url").val();
		var email = $("#email").val();
		if(isBlank(author) && is_user_logged_in==0) {
			statusdiv.html('<p  class="ajax-error">请输入昵称！</p>').show();
		} else if(isBlank(email)  && is_user_logged_in==0) {
			statusdiv.html('<p  class="ajax-error">请输入邮箱！</p>').show();
		} else {
			// var formdata=commentform.serialize() + "&comment=" + noteContent ;
			// 添加状态信息
			statusdiv.html('<p>Processing...</p>').show();
			// 获取表单提交地址
			var formurl=commentform.attr('action');
			
			// 异步提交
			$.ajax({
					type: 'post',
					url: formurl,
					dataType:'json',
					data: {"comment_parent":comment_parent,"comment_post_ID":comment_post_ID, "_wp_unfiltered_html_comment":_wp_unfiltered_html_comment,"comment":comment,"url":url, "email":email,"author":author},
					error: function(XMLHttpRequest, textStatus, errorThrown){
					statusdiv.html('<p class="ajax-error" >数据不完整或表单提交太快了！</p>').show();
				},
				success: function(data, textStatus){
					if(data.errorno=="0") {
						$("#submit").prop('disabled', true);
						statusdiv.html('<p class="ajax-success" >笔记已提交审核，感谢分享笔记！</p>').show();
						alert('笔记已提交审核，感谢分享笔记！');
					}else{
						statusdiv.html('<p class="ajax-error" >'+data.msg+'</p>').show();
					}
					commentform.find('textarea[name=comment]').val('');
				}
			});
			setTimeout(function(){
		        $("#submit").prop('disabled', false);
		    }, 10*1000);
		}
		return false;

	});
	$(".comt-author").click(function() {
		href = $(this).children("a").attr("href");
		if(href.indexOf("/note/")!=-1) {
			var win = window.open(href, '_blank');
  			win.focus();
		}
	});
	$(".comt-meta span").hover(function(){
		$(this).children(".tooltip").css({ "opacity": 1, "pointer-events": "auto"});
	},function(){
		$(this).children(".tooltip").removeAttr("style");
	});
	/*
	$(".wrapper i").hover(function(){
		$(this).siblings(".tooltip").css({ "opacity": 1, "pointer-events": "auto"});
	},function(){
		$(this).siblings(".tooltip").css({ "opacity": 0, "pointer-events": "auto"});
	});
	*/
	//Upvote.create('runoobvote-id', {callback: vote_callback});
	var ajaxurl = 'https://www.runoob.com/wp-admin/admin-ajax.php';
	var callback = function(data) {
		//console.log($('#runoobvote-id').upvote('upvoted'));
		//console.log($('#runoobvote-id').upvote('downvoted'));
		//console.log(data);
		_vote_action = data.action;
		id_arr = data.id.split('-');
		um_id= id_arr[2];
		//console.log(um_id);
		
		var re = /^[1-9]+/;
		if (re.test(um_id)) { 
			var ajax_data = {
				_vote_action: _vote_action,
				action: "pinglun_zan",
				um_id: um_id,
				um_action: "ding"
			};
			//console.log(ajax_data);
			$.post(ajaxurl,ajax_data,function(status){
				//if(status.vote_num>999) {
				//	_voteHtml = '<span style="display: block; text-align: center;font-size: 20px; color: #6a737c; margin: 8px 0;">'+kFormatter(status.vote_num) +'</span>';
				//	$("#runoobvote-id-" + um_id + " .count").hide().after(_voteHtml);
				//}
				
			});
		}
	};
	if($('#comments').length && $('.upvotejs').length){
		$('.upvotejs').upvote({id: 15437, callback: callback});
	
		$.post(ajaxurl,{"action":"pinglun_zan","postid":15437},function(data){  
			$(data).each(function(key,value) {
				$("#runoobvote-id-" + value.commid + " .upvote").addClass(value.upvotejs_class);
				$("#runoobvote-id-" + value.commid + " .downvote").addClass(value.downvote_class);
				$("#runoobvote-id-" + value.commid + " .count").text(value.upvote_count);
			})
		},'json');
		
	}
	
	
});
function isBlank(str) {
    return (!str || /^\s*$/.test(str));
}
function kFormatter(num) {
	// return num;
    return Math.abs(num) > 999 ? Math.sign(num)*((Math.abs(num)/1000).toFixed(1)) + 'k' : Math.sign(num)*Math.abs(num)
}

</script>

<link rel="stylesheet" href="../0/qa.css?1.44">
<link rel="stylesheet" type="text/css" href="../0/simditor.min.css" />
<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>
		<div class="sidebar-box ">
				

<style>	
.responsive_ad1 { display:none; }
@media(min-width: 800px) { .responsive_ad1 {  display:block;margin:0 auto;} }
</style>
<div id="ad-336280" >

<script async src=""
     crossorigin="anonymous"></script>
<!-- 移动版 自动调整 -->
<ins class="adsbygoogle"
     style="display:block"
     data-ad-client="ca-pub-5751451760833794"
     data-ad-slot="1691338467"
     data-ad-format="auto"
     data-full-width-responsive="true"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
		</div>
				</div>
		
	</div>
</div>
	

<!-- 右边栏 -->
<div class="fivecol last right-column">

<style>
.sidebar-tree .double-li {
    width:300px;
}
.sidebar-tree .double-li li {
    width: 44%;
    line-height: 1.5em;
    border-bottom: 1px solid #ccc;
    float: left;
    display: inline;
}
</style>

    
        <div class="sidebar-box re-box re-box-large">
        <div class="sidebar-box recommend-here" style="margin: 0 auto;">
            <a href="javascript:void(0);" style="font-size: 16px; color:#64854c;font-weight:bold;"> <i class="fa fa-list" aria-hidden="true"></i> 分类导航</a>
        </div>
    <div class="sidebar-box sidebar-cate">
        
        <div class="sidebar-tree" >
            <ul><li style="margin: 0;"><a href="javascript:void(0);" class="tit"> HTML / CSS</a><ul class="double-li"><li><a title="HTML 教程" href="../html/html-tutorial.html">HTML 教程</a></li><li><a title="HTML5 教程" href="../html/html5-intro.html">HTML5 教程</a></li><li><a title="CSS 教程" href="../css/css-tutorial.html">CSS 教程</a></li><li><a title="CSS3 教程" href="../css3/css3-tutorial.html">CSS3 教程</a></li><li><a title="Bootstrap3 教程" href="../bootstrap/bootstrap-tutorial.html">Bootstrap3 教程</a></li><li><a title="Bootstrap4 教程" href="../bootstrap4/bootstrap4-tutorial.html">Bootstrap4 教程</a></li><li><a title="Bootstrap5 教程" href="../bootstrap5/bootstrap5-tutorial.html">Bootstrap5 教程</a></li><li><a title="Font Awesome 教程" href="../font-awesome/fontawesome-tutorial.html">Font Awesome 教程</a></li><li><a title="Foundation 教程" href="../foundation/foundation-tutorial.html">Foundation 教程</a></li></ul></li><li style="margin: 0;"><a href="javascript:void(0);" class="tit"> JavaScript</a><ul class="double-li"><li><a title="JavaScript 教程" href="../js/js-tutorial.html">JavaScript 教程</a></li><li><a title="HTML DOM 教程" href="../htmldom/htmldom-tutorial.html">HTML DOM 教程</a></li><li><a title="jQuery 教程" href="../jquery/jquery-tutorial.html">jQuery 教程</a></li><li><a title="AngularJS 教程" href="../angularjs/angularjs-tutorial.html">AngularJS 教程</a></li><li><a title="AngularJS2 教程" href="../angularjs2/angularjs2-tutorial.html">AngularJS2 教程</a></li><li><a title="Vue.js 教程" href="../vue2/vue-tutorial.html">Vue.js 教程</a></li><li><a title="Vue3 教程" href="../vue3/vue3-tutorial.html">Vue3 教程</a></li><li><a title="React 教程" href="../react/react-tutorial.html">React 教程</a></li><li><a title="TypeScript 教程" href="../typescript/ts-tutorial.html">TypeScript 教程</a></li><li><a title="jQuery UI 教程" href="../jqueryui/jqueryui-tutorial.html">jQuery UI 教程</a></li><li><a title="jQuery EasyUI 教程" href="../jeasyui/jqueryeasyui-tutorial.html">jQuery EasyUI 教程</a></li><li><a title="Node.js 教程" href="../nodejs/nodejs-tutorial.html">Node.js 教程</a></li><li><a title="AJAX 教程" href="../ajax/ajax-tutorial.html">AJAX 教程</a></li><li><a title="JSON 教程" href="../json/json-tutorial.html">JSON 教程</a></li><li><a title="Echarts 教程" href="../echarts/echarts-tutorial.html">Echarts 教程</a></li><li><a title="Chart.js 教程" href="../chartjs/chartjs-tutorial.html">Chart.js 教程</a></li><li><a title="Highcharts 教程" href="../highcharts/highcharts-tutorial.html">Highcharts 教程</a></li><li><a title="Google 地图 教程" href="../googleapi/google-maps-basic.html">Google 地图 教程</a></li></ul></li><li style="margin: 0;"><a href="javascript:void(0);" class="tit"> 服务端</a><ul class="double-li"><li><a title="Python 教程" href="../python3/python3-tutorial.html">Python 教程</a></li><li><a title="Python2.x 教程" href="../python/python-tutorial.html">Python2.x 教程</a></li><li><a title="Linux 教程" href="../linux/linux-tutorial.html">Linux 教程</a></li><li><a title="Docker 教程" href="../docker/docker-tutorial.html">Docker 教程</a></li><li><a title="Ruby 教程" href="../ruby/ruby-tutorial.html">Ruby 教程</a></li><li><a title="Java 教程" href="../java/java-tutorial.html">Java 教程</a></li><li><a title="C 教程" href="../c/c-tutorial.html">C 教程</a></li><li><a title="C++ 教程" href="../cplusplus/cpp-tutorial.html">C++ 教程</a></li><li><a title="Perl 教程" href="../perl/perl-tutorial.html">Perl 教程</a></li><li><a title="Servlet 教程" href="../servlet/servlet-tutorial.html">Servlet 教程</a></li><li><a title="JSP 教程" href="../jsp/jsp-tutorial.html">JSP 教程</a></li><li><a title="Lua 教程" href="../lua/lua-tutorial.html">Lua 教程</a></li><li><a title="Rust 教程" href="../rust/rust-tutorial.html">Rust 教程</a></li><li><a title="Scala 教程" href="../scala/scala-tutorial.html">Scala 教程</a></li><li><a title="Go 教程" href="../go/go-tutorial.html">Go 教程</a></li><li><a title="PHP 教程" href="../php/php-tutorial.html">PHP 教程</a></li><li><a title="数据结构与算法" href="../data-structures/data-structures-tutorial.html">数据结构与算法</a></li><li><a title="Django 教程" href="../django/django-tutorial.html">Django 教程</a></li><li><a title="Zookeeper 教程" href="../w3cnote/zookeeper-tutorial.html">Zookeeper 教程</a></li><li><a title="设计模式" href="../design-pattern/design-pattern-tutorial.html">设计模式</a></li><li><a title="正则表达式" href="../regexp/regexp-tutorial.html">正则表达式</a></li><li><a title="Maven 教程" href="../maven/maven-tutorial.html">Maven 教程</a></li><li><a title="Verilog 教程" href="../w3cnote/verilog-tutorial.html">Verilog 教程</a></li><li><a title="ASP 教程" href="../asp/asp-tutorial.html">ASP 教程</a></li><li><a title="AppML 教程" href="../appml/appml-tutorial.html">AppML 教程</a></li><li><a title="VBScript 教程" href="../vbscript/vbscript-tutorial.html">VBScript 教程</a></li></ul></li><li style="margin: 0;"><a href="javascript:void(0);" class="tit"> 数据库</a><ul class="double-li"><li><a title="SQL 教程" href="../sql/sql-tutorial.html">SQL 教程</a></li><li><a title="MySQL 教程" href="../mysql/mysql-tutorial.html">MySQL 教程</a></li><li><a title="PostgreSQL 教程" href="../postgresql/postgresql-tutorial.html">PostgreSQL 教程</a></li><li><a title="SQLite 教程" href="../sqlite/sqlite-tutorial.html">SQLite 教程</a></li><li><a title="MongoDB 教程" href="../mongodb/mongodb-tutorial.html">MongoDB 教程</a></li><li><a title="Redis 教程" href="../redis/redis-tutorial.html">Redis 教程</a></li><li><a title="Memcached 教程" href="../Memcached/Memcached-tutorial.html">Memcached 教程</a></li></ul></li><li style="margin: 0;"><a href="javascript:void(0);" class="tit"> 数据分析</a><ul class="double-li"><li><a title="Python 教程" href="../python3/python3-tutorial.html">Python 教程</a></li><li><a title="NumPy 教程" href="../numpy/numpy-tutorial.html">NumPy 教程</a></li><li><a title="Pandas 教程" href="../pandas/pandas-tutorial.html">Pandas 教程</a></li><li><a title="Matplotlib 教程" href="../matplotlib/matplotlib-tutorial.html">Matplotlib 教程</a></li><li><a title="Scipy 教程" href="../scipy/scipy-tutorial.html">Scipy 教程</a></li><li><a title="R 教程" href="../r/r-tutorial.html">R 教程</a></li><li><a title="Julia 教程" href="../julia/julia-tutorial.html">Julia 教程</a></li></ul></li><li style="margin: 0;"><a href="javascript:void(0);" class="tit"> 移动端</a><ul class="double-li"><li><a title="Android 教程" href="../w3cnote/android-tutorial-intro.html">Android 教程</a></li><li><a title="Swift 教程" href="../swift/swift-tutorial.html">Swift 教程</a></li><li><a title="jQuery Mobile 教程" href="../jquerymobile/jquerymobile-tutorial.html">jQuery Mobile 教程</a></li><li><a title="ionic 教程" href="../ionic/ionic-tutorial.html">ionic 教程</a></li><li><a title="Kotlin 教程" href="../kotlin/kotlin-tutorial.html">Kotlin 教程</a></li></ul></li><li style="margin: 0;"><a href="javascript:void(0);" class="tit"> XML 教程</a><ul class="double-li"><li><a title="XML 教程" href="../xml/xml-tutorial.html">XML 教程</a></li><li><a title="DTD 教程" href="../dtd/dtd-tutorial.html">DTD 教程</a></li><li><a title="XML DOM 教程" href="../dom/dom-tutorial.html">XML DOM 教程</a></li><li><a title="XSLT 教程" href="../xsl/xsl-tutorial.html">XSLT 教程</a></li><li><a title="XPath 教程" href="../xpath/xpath-tutorial.html">XPath 教程</a></li><li><a title="XQuery 教程" href="../xquery/xquery-tutorial.html">XQuery 教程</a></li><li><a title="XLink 教程" href="../xlink/xlink-tutorial.html">XLink 教程</a></li><li><a title="XPointer 教程" href="../xlink/xlink-tutorial.html">XPointer 教程</a></li><li><a title="XML Schema 教程" href="../schema/schema-tutorial.html">XML Schema 教程</a></li><li><a title="XSL-FO 教程" href="../xslfo/xslfo-tutorial.html">XSL-FO 教程</a></li><li><a title="SVG 教程" href="../svg/svg-tutorial.html">SVG 教程</a></li></ul></li><li style="margin: 0;"><a href="javascript:void(0);" class="tit"> ASP.NET</a><ul class="double-li"><li><a title="ASP.NET 教程" href="../aspnet/aspnet-tutorial.html">ASP.NET 教程</a></li><li><a title="C# 教程" href="../csharp/csharp-tutorial.html">C# 教程</a></li><li><a title="Web Pages 教程" href="../aspnet/webpages-intro.html">Web Pages 教程</a></li><li><a title="Razor 教程" href="../aspnet/razor-intro.html">Razor 教程</a></li><li><a title="MVC 教程" href="../aspnet/mvc-intro.html">MVC 教程</a></li><li><a title="Web Forms 教程" href="../aspnet/aspnet-intro.html">Web Forms 教程</a></li></ul></li><li style="margin: 0;"><a href="javascript:void(0);" class="tit"> Web Service</a><ul class="double-li"><li><a title="Web Service 教程" href="../webservices/webservices-tutorial.html">Web Service 教程</a></li><li><a title="WSDL 教程" href="../wsdl/wsdl-tutorial.html">WSDL 教程</a></li><li><a title="SOAP 教程" href="../soap/soap-tutorial.html">SOAP 教程</a></li><li><a title="RSS 教程" href="../rss/rss-tutorial.html">RSS 教程</a></li><li><a title="RDF 教程" href="../rdf/rdf-tutorial.html">RDF 教程</a></li></ul></li><li style="margin: 0;"><a href="javascript:void(0);" class="tit"> 开发工具</a><ul class="double-li"><li><a title="Eclipse 教程" href="../eclipse/eclipse-tutorial.html">Eclipse 教程</a></li><li><a title="Git 教程" href="../git/git-tutorial.html">Git 教程</a></li><li><a title="Svn 教程" href="../svn/svn-tutorial.html">Svn 教程</a></li><li><a title="Markdown 教程" href="../markdown/md-tutorial.html">Markdown 教程</a></li></ul></li><li style="margin: 0;"><a href="javascript:void(0);" class="tit"> 网站建设</a><ul class="double-li"><li><a title="HTTP 教程" href="../http/http-tutorial.html">HTTP 教程</a></li><li><a title="网站建设指南" href="../web/web-buildingprimer.html">网站建设指南</a></li><li><a title="浏览器信息" href="../browsers/browser-information.html">浏览器信息</a></li><li><a title="网站主机教程" href="../hosting/hosting-tutorial.html">网站主机教程</a></li><li><a title="TCP/IP 教程" href="../tcpip/tcpip-tutorial.html">TCP/IP 教程</a></li><li><a title="W3C 教程" href="../w3c/w3c-tutorial.html">W3C 教程</a></li><li><a title="网站品质" href="../quality/quality-tutorial.html">网站品质</a></li></ul></li></ul>            </div>
    
    </div>
    </div>
    <br>
    
    <div class="sidebar-box re-box re-box-large">
        <div class="sidebar-box recommend-here">
            <a href="javascript:void(0);">Advertisement</a>
        </div>
        <div class="re-600160" id="sidebar-right-re">
                <script async src=""></script>
        <!-- 侧栏1 -->
        <ins class="adsbygoogle"
             style="display:inline-block;width:160px;height:600px"
             data-ad-client="ca-pub-5751451760833794"
             data-ad-slot="4106274865"></ins>
        <script>
        (adsbygoogle = window.adsbygoogle || []).push({});
        </script>
                </div>
    </div>
</div></div>

</div>

<script>
var aid = 15437;
function coll() {
	$.post( '/wp-content/themes/runoob/option/user/userinfo.php', {aid:aid, action:"collarticle", opt:'add'},function( data ) {
		if(data.error==0) {
			$("#content").find("h1:first").find("a").attr("href","javascript:void(0);");
			$("#content").find("h1:first").find("img").attr("src","http://www.runoob.com/wp-content/themes/runoob/assets/img/coll2.png").css({width:32+"px",height:32+"px"});
		}
		alert(data.msg);
	},'json');
}
</script>


<!-- 反馈对话框开始 -->
<script src=""></script>
<link rel="stylesheet" href="../0/feedback.css?1.0" />
<script type="text/javascript">
$.feedback({
    ajaxURL: '/feedback/runoob_feedback.php',
	html2canvasURL: '/wp-content/themes/runoob/assets/feedback/stable/2.0/html2canvas.js',
	onClose: function () {
         window.location.reload();
    }
});
</script>
<!-- 反馈对话框结束 -->
<button class="feedback-btn feedback-btn-gray">反馈/建议</button>
<!-- 底部 -->
<div id="footer" class="mar-t50">
   <div class="runoob-block">
    <div class="runoob cf">
     <dl>
      <dt>
       在线实例
      </dt>
      <dd>
       &middot;<a target="_blank" href="../html/html-examples.html">HTML 实例</a>
      </dd>
      <dd>
       &middot;<a target="_blank" href="../css/css-examples.html">CSS 实例</a>
      </dd>
      <dd>
       &middot;<a target="_blank" href="../js/js-examples.html">JavaScript 实例</a>
      </dd>
      <dd>
       &middot;<a target="_blank" href="../ajx/ajax-examples.html">Ajax 实例</a>
      </dd>
       <dd>
       &middot;<a target="_blank" href="../jquery/jquery-examples.html">jQuery 实例</a>
      </dd>
      <dd>
       &middot;<a target="_blank" href="../xml/xml-examples.html">XML 实例</a>
      </dd>
      <dd>
       &middot;<a target="_blank" href="../java/java-examples.html">Java 实例</a>
      </dd>
     
     </dl>
     <dl>
      <dt>
      字符集&工具
      </dt>
      <dd>
       &middot; <a target="_blank" href="../charsets/html-charsets.html">HTML 字符集设置</a>
      </dd>
      <dd>
       &middot; <a target="_blank" href="../tags/html-ascii.html">HTML ASCII 字符集</a>
      </dd>
     <dd>
       &middot; <a target="_blank" href="https://c.runoob.com/front-end/6939/">JS 混淆/加密</a>
      </dd> 
      <dd>
       &middot; <a target="_blank" href="https://c.runoob.com/front-end/6232/">PNG/JPEG 图片压缩</a>
      </dd>
      <dd>
       &middot; <a target="_blank" href="../tags/html-colorpicker.html">HTML 拾色器</a>
      </dd>
      <dd>
       &middot; <a target="_blank" href="..//c.runoob.com/front-end/53">JSON 格式化工具</a>
      </dd>
      <dd>
       &middot; <a target="_blank" href="..//c.runoob.com/front-end/6680/">随机数生成器</a>
      </dd>
     </dl>
     <dl>
      <dt>
       最新更新
      </dt>
                   <dd>
       &middot;
      <a href="../matplotlib/matplotlib-imread.html" title="Matplotlib imread() 方法">Matplotlib imre...</a>
      </dd>
              <dd>
       &middot;
      <a href="../matplotlib/matplotlib-imsave.html" title="Matplotlib imsave() 方法">Matplotlib imsa...</a>
      </dd>
              <dd>
       &middot;
      <a href="../matplotlib/matplotlib-imshow.html" title="Matplotlib imshow() 方法">Matplotlib imsh...</a>
      </dd>
              <dd>
       &middot;
      <a href="../matplotlib/matplotlib-hist.html" title="Matplotlib 直方图">Matplotlib 直方图</a>
      </dd>
              <dd>
       &middot;
      <a href="../python3/python-func-object.html" title="Python object() 函数">Python object()...</a>
      </dd>
              <dd>
       &middot;
      <a href="../python3/python-ai-draw.html" title="Python AI 绘画">Python AI 绘画</a>
      </dd>
              <dd>
       &middot;
      <a href="../w3cnote/cursor-editor.html" title="神辅助 Cursor 编辑器，加入 GPT-4 让编码更轻松！">神辅助 Cursor ...</a>
      </dd>
             </dl>
     <dl>
      <dt>
       站点信息
      </dt>
      <dd>
       &middot;
       <a target="_blank" href="mailto:admin@runoob.com" rel="external nofollow">意见反馈</a>
       </dd>
      <dd>
       &middot;
      <a target="_blank" href="../disclaimer">免责声明</a>
       </dd>
      <dd>
       &middot;
       <a target="_blank" href="../aboutus">关于我们</a>
       </dd>
      <dd>
       &middot;
      <a target="_blank" href="../archives">文章归档</a>
      </dd>
    
     </dl>
    
     <div class="search-share">
      <div class="app-download">
        <div>
         <strong>关注微信</strong>
        </div>
      </div>
      <div class="share">
      <img width="128" height="128" src="/wp-content/themes/runoob/assets/images/qrcode.png" />
       </div>
     </div>
     
    </div>
   </div>
   <div class="w-1000 copyright">
     Copyright &copy; 2013-2023    <strong><a href="../" target="_blank">菜鸟教程</a></strong>&nbsp;
    <strong><a href="../" target="_blank">runoob.com</a></strong> All Rights Reserved. 备案号：<a target="_blank" rel="nofollow" href="https://beian.miit.gov.cn/">闽ICP备15012807号-1</a>
   </div>
  </div>
  <div class="fixed-btn">
    <a class="go-top" href="javascript:void(0)" title="返回顶部"> <i class="fa fa-angle-up"></i></a>
    <a class="qrcode"  href="javascript:void(0)" title="关注我们"><i class="fa fa-qrcode"></i></a>
    <a class="writer" style="display:none" href="javascript:void(0)"   title="标记/收藏"><i class="fa fa-star" aria-hidden="true"></i></a>
    <!-- qrcode modal -->
    <div id="bottom-qrcode" class="modal panel-modal hide fade in">
      <h4>微信关注</h4>
      <div class="panel-body"><img alt="微信关注" width="128" height="128" src="/wp-content/themes/runoob/assets/images/qrcode.png"></div> 
    </div>
  </div>

 <div style="display:none;">
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-84264393-2"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'UA-84264393-2');
</script>
<script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?3eec0b7da6548cf07db3bc477ea905ee";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script>

</div>
<script>
window.jsui={
    www: 'https://www.runoob.com',
    uri: 'https://www.runoob.com/wp-content/themes/runoob'
};
</script>

<script src=""></script>
<script src=""></script>

</body>
</html>